package jsf.uss.models;

import java.io.Serializable;
import java.util.List;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 * The persistent class for the clients database table.
 * 
 */
@Entity
@Table(name = "clients")
@NamedQuery(name = "Client.findAllIds", query = "SELECT c.clientId FROM Client c")
public class Client implements Serializable {
    private static final long serialVersionUID = 1L;

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long	      clientId;

    private String	    address;

    private String	    email;

    private String	    name;

    // bi-directional many-to-one association to Order
    @OneToMany(mappedBy = "client")
    private List<Order>       orders;

    public Client() {
    }

    public Long getClientId() {
	return this.clientId;
    }

    public void setClientId(Long clientId) {
	this.clientId = clientId;
    }

    public String getAddress() {
	return this.address;
    }

    public void setAddress(String address) {
	this.address = address;
    }

    public String getEmail() {
	return this.email;
    }

    public void setEmail(String email) {
	this.email = email;
    }

    public String getName() {
	return this.name;
    }

    public void setName(String name) {
	this.name = name;
    }

    public List<Order> getOrders() {
	return this.orders;
    }

    public void setOrders(List<Order> orders) {
	this.orders = orders;
    }

    public Order addOrder(Order order) {
	getOrders().add(order);
	order.setClient(this);

	return order;
    }

    public Order removeOrder(Order order) {
	getOrders().remove(order);
	order.setClient(null);

	return order;
    }

}